package factorytest.iflytek.com.einkiflytekfactorytest.factorytestui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.Button;

public class PCBATestBtnView extends Button {

    private boolean isETP;
    public PCBATestBtnView(Context context) {
        super(context);
    }

    public PCBATestBtnView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public PCBATestBtnView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public PCBATestBtnView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        if (!(event.getPointerCount() == 1
                && event.getToolType(0) == (isETP() ? MotionEvent.TOOL_TYPE_STYLUS : MotionEvent.TOOL_TYPE_FINGER))) {

            return false;
        }
        return super.dispatchTouchEvent(event);
    }

    public boolean isETP() {
        return isETP;
    }

    public void setETP(boolean ETP) {
        isETP = ETP;
    }
}
